package ylsb.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import ylsb.dao.HcjieguoMapper;
import ylsb.model.*;
import ylsb.service.*;
import ylsb.support.CreateXLS;
import ylsb.support.JsonResult;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;

@RestController
@RequestMapping("jieguo")
public class YltpjieguoController {
    @Value("${userfilepath}")
    private String userfilepath;
    @Resource
    YltpjieguoService ddService;
    @Resource
    HcjieguoMapper hcjieguoMapper;
    @Resource
    YltpbaofeiService ddYltpbaofeiService;
    @Resource
    ShebeiService ddShebeiService;
    @Resource
    YltpyinjinService ddYltpyinjinService;
    @Resource
    YltphaocaiduibiaoService ddYltphaocaiduibiaoService;
    @Resource
    YltpzhuankeyinjinService ddYltpzhuankeyinjinService;
    @Resource
    YltpjieguoService ddYltpjieguoService;
    @Resource
    YltpXiangmuService ddYltpXiangmuService;
    @Resource
    HaocaiyinjinService ddHaocaiyinjinService;
    @Resource
    YltprenyuanfenpeiService ddYltprenyuanfenpeiService;
    @Resource
    DailiangchuangxinService ddDailiangchuangxinService;
    @Resource
    YltpuserService ddYltpuserService;
    @Resource
    Hc45Service hc45Service;
    @Resource
    HcjieguoService hcjieguoService;

    public Logger log = LoggerFactory.getLogger(YltpjieguoController.class);

    @RequestMapping("getjindulist")
    public JsonResult<?> getjindulist(@RequestParam("xiangmuid") String ppxiangmuId,
                                      @RequestParam("xiangmuleixing") String ppxiangmuleixiang) {
        try {
            List<Map<String, Object>> mmJindulist = new ArrayList<>();
            Integer mmTotal = 0;
            mmTotal = ddYltpjieguoService.getVoteCount(ppxiangmuId,ppxiangmuleixiang).get("pinguiCount");


            List<Map<String, Object>> mmUserList = ddYltprenyuanfenpeiService.findRenyuanFenpeiByXiangmuId(ppxiangmuId);
            if(ppxiangmuleixiang.equals("29"))mmTotal = hc45Service.getPinzhongCount(ppxiangmuId);
            if(ppxiangmuleixiang.equals("24")||ppxiangmuleixiang.equals("25")||ppxiangmuleixiang.equals("27"))mmTotal = hc45Service.getPinpaiCount(ppxiangmuId);
            for (Map<String, Object> ysrenyuanfenpei : mmUserList) {
                Map<String, Object> mmMap = new HashMap<String, Object>();
                String mmUserId = ysrenyuanfenpei.get("userid").toString();
                YltpUser mmuser = ddYltpuserService.findOne(mmUserId);
                String mmUserName = mmuser.getUsername();
                Integer mmpinguishu = 0;
                mmpinguishu = ddYltpjieguoService.getResultCount(ppxiangmuId, ppxiangmuleixiang,mmUserId, "1");
                if(ppxiangmuleixiang.equals("29"))mmpinguishu = hcjieguoService.getPinzhongResultCount(ppxiangmuId, mmUserId, "1");
                if(ppxiangmuleixiang.equals("24")||ppxiangmuleixiang.equals("25")||ppxiangmuleixiang.equals("27"))mmpinguishu = hcjieguoService.getPinpaiResultCount(ppxiangmuId, mmUserId, "1");


                String mmShifoutijiao = "";
                if ("1".equals(ysrenyuanfenpei.get("issubmit").toString())) {
                    mmShifoutijiao = "是";
                } else {
                    mmShifoutijiao = "否";
                }
                mmMap.put("username", mmUserName);
                mmMap.put("pinguishu", mmpinguishu + "/" + mmTotal);
                mmMap.put("shifoutijiao", mmShifoutijiao);
                mmJindulist.add(mmMap);
            }

            return JsonResult.getSuccessResult(mmJindulist);
        } catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getjindulist:error", e);
            return JsonResult.getErrorResult("jieguo/getjindulist:error " + e.getMessage());
        }
    }

    @RequestMapping("getChuangxinchanpinResultCount")
    public JsonResult<?> getChuangxinchanpinResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                                        @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getChuangxinchanpinResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmTotal=ddDailiangchuangxinService.getChuangxinCount(ppxiangmuId);
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("total", mmTotal);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getChuangxinchanpinResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getChuangxinchanpinResultCount:error " + e.getMessage());
        }
    }

    @RequestMapping("getHaocaiduibiaoResultCount")
    public JsonResult<?> getHaocaiduibiaoResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                              @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getHaocaiduibiaoResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmButongyishu=ddService.getHaocaiduibiaoResultCount(ppxiangmuId,ppuserId,"0");
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getHaocaiduibiaoResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getHaocaiduibiaoResultCount:error " + e.getMessage());
        }
    }
    @RequestMapping("getZhuankeyinjinResultCount")
    public JsonResult<?> getZhuankeyinjinResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                                                         @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getZhuankeyinjinResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmButongyishu=ddService.getZhuankeyinjinResultCount(ppxiangmuId,ppuserId,"0");
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getZhuankeyinjinResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getZhuankeyinjinResultCount:error " + e.getMessage());
        }
    }

    @RequestMapping("getBaofeiResultCount")
    public JsonResult<?> getBaofeiResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                         @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getBaofeiResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmButongyishu=ddService.getBaofeiResultCount(ppxiangmuId,ppuserId,"0");
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getBaofeiResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getBaofeiResultCount:error " + e.getMessage());
        }
    }

    @RequestMapping("getYinjinResultCount")
    public JsonResult<?> getYinjinResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                              @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getYinjinResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmButongyishu=ddService.getYinjinResultCount(ppxiangmuId,ppuserId,"0");
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getYinjinResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getYinjinResultCount:error " + e.getMessage());
        }
    }

    @RequestMapping("getShebeiResultCount")
    public JsonResult<?> getShebeiResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                              @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getShebeiResultCount(ppxiangmuId,ppuserId,"1");
            Integer mmButongyishu=ddService.getShebeiResultCount(ppxiangmuId,ppuserId,"0");
            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getResultCount:error " + e.getMessage());
        }
    }
    @RequestMapping("getResultCount")
    public JsonResult<?> getResultCount(@RequestParam("xiangmuid") String ppxiangmuId,
                                        @RequestParam("xiangmuleixing") String ppxiangmuleixing,
                                              @RequestParam("userid") String ppuserId){
        try {
            Integer mmTongyishu=ddService.getResultCount(ppxiangmuId,ppxiangmuleixing,ppuserId,"1");
            Integer mmButongyishu=ddService.getResultCount(ppxiangmuId,ppxiangmuleixing,ppuserId,"0");
            Map<String,Integer> voteCount=ddService.getVoteCount(ppxiangmuId,ppxiangmuleixing);

            Map<String, Object> mmMap = new HashMap<String, Object>();
            mmMap.put("tongyiShu", mmTongyishu);
            mmMap.put("butongyiShu", mmButongyishu);
            mmMap.put("total", voteCount.get("pinguiCount"));
            return JsonResult.getSuccessResult(mmMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/getResultCount:error",e);
            return JsonResult.getErrorResult("jieguo/getResultCount:error " + e.getMessage());
        }
    }
    @RequestMapping("toupiao")
    public JsonResult<?> toupiao(@RequestParam("id") String ppdetailId,
                                 @RequestParam("userid") String ppuserId,
                                 @RequestParam("result") String ppresult){

        try {
            YltpJieguo mmYltpJieguo=new YltpJieguo();
            if(ddService.checkexistBydetailanduserId(ppdetailId,ppuserId)!=null){
                String mmId=ddService.checkexistBydetailanduserId(ppdetailId,ppuserId).getId();
                mmYltpJieguo.setId(mmId);
                mmYltpJieguo.setResult(ppresult);
                return ddService.modify(mmYltpJieguo)==true? JsonResult.getSuccessResult("表决成功")
                        : JsonResult.getErrorResult("表决失败");
            }else{

                mmYltpJieguo.setId(UUID.randomUUID().toString());
                mmYltpJieguo.setDetailid(ppdetailId);
                mmYltpJieguo.setUserid(ppuserId);
                mmYltpJieguo.setResult(ppresult);
                return ddService.add(mmYltpJieguo)==true? JsonResult.getSuccessResult("表决成功")
                        : JsonResult.getErrorResult("表决失败");
            }

        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/toupiao:error",e);
            return JsonResult.getErrorResult("jieguo/toupiao:error " + e.getMessage());
        }
    }


    @RequestMapping("toupiao_all")
    public JsonResult<?> toupiaoall(@RequestParam("xiangmuid") String ppxiangmuId,
                                    @RequestParam("result") String ppresult,
                                 @RequestParam("userid") String ppuserId){
        try {

            List<Map<String, Object>> mmList=null;
            YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuId);
/*            if("1".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddYltpyinjinService.findBiaojuelist(ppxiangmuId,ppuserId);
            }else{
                return JsonResult.getErrorResult("没有此类型");
            }*/
            mmList=ddYltpjieguoService.findBiaojuelist(ppxiangmuId,mmYltpXiangmu.getXiangmuleixing(),ppuserId);
          /*  else if("2".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddYltpbaofeiService.findBiaojuelist(ppxiangmuId,ppuserId);
            }
            else if("3".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddYltphaocaiduibiaoService.findBiaojuelist(ppxiangmuId,ppuserId);
            }
            else if("4".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddYltpzhuankeyinjinService.findBiaojuelist(ppxiangmuId,ppuserId);
            }
            if("12".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddShebeiService.findBiaojuelist(ppxiangmuId,ppuserId);
            }*/
            if (mmList != null && !mmList.isEmpty()) {
                List<YltpJieguo> addList = new ArrayList<>();
                List<YltpJieguo> updateList = new ArrayList<>();
                for (Map<String, Object> mm : mmList) {
                    String mmdetailId = mm.get("id").toString();
                    YltpJieguo mmyltpjg = ddService.checkexistBydetailanduserId(mmdetailId, ppuserId);

                    if (mmyltpjg != null) {
                        YltpJieguo mmYltpJieguo = new YltpJieguo();
                        mmYltpJieguo.setId(mmyltpjg.getId());
                        mmYltpJieguo.setResult(ppresult);
                        updateList.add(mmYltpJieguo);
                    } else if (mm.get("isvote").toString().equals("1")) {
                        YltpJieguo mmYltpJieguo = new YltpJieguo();
                        mmYltpJieguo.setId(UUID.randomUUID().toString());
                        mmYltpJieguo.setDetailid(mmdetailId);
                        mmYltpJieguo.setUserid(ppuserId);
                        mmYltpJieguo.setResult(ppresult);
                        addList.add(mmYltpJieguo);
                    }
                }

                ddService.batchAddOrUpdate(addList,updateList);

            }

           /* if("8".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddDailiangchuangxinService.findBiaojuelist(ppxiangmuId,ppuserId);
            } else if("9".equals(mmYltpXiangmu.getXiangmuleixing())){
                mmList=ddDailiangchuangxinService.findBiaojuelist(ppxiangmuId,ppuserId);
            }*/

           /* if(mmList!=null){
                for (int i = 0; i < mmList.size(); i++){
                    YltpJieguo mmYltpJieguo=new YltpJieguo();
                    String mmdetailId=mmList.get(i).get("id").toString();
                    if(ddService.checkexistBydetailanduserId(mmdetailId,ppuserId)!=null){
                        String mmId=ddService.checkexistBydetailanduserId(mmdetailId,ppuserId).getId();
                        mmYltpJieguo.setId(mmId);
                        mmYltpJieguo.setResult("1");
                        ddService.modify(mmYltpJieguo);
                    }else{
                        mmYltpJieguo.setId(UUID.randomUUID().toString());
                        mmYltpJieguo.setDetailid(mmdetailId);
                        mmYltpJieguo.setUserid(ppuserId);
                        mmYltpJieguo.setResult("1");
                        ddService.add(mmYltpJieguo);
                    }
                }
            }else{
                return JsonResult.getErrorResult("表决全部错误");
            }*/
            return JsonResult.getSuccessResult("表决全部成功");
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/toupiao_all:error",e);
            return JsonResult.getErrorResult("jieguo/toupiao_all:error " + e.getMessage());
        }
    }
    @RequestMapping("toupiao_all2")
    public JsonResult<?> toupiaoall2(@RequestParam("xiangmuid") String ppxiangmuId,
                                    @RequestParam("result") String ppresult,
                                 @RequestParam("userid") String ppuserId){
        try {

            List<Map<String, Object>> mmList=null;
            YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuId);
            mmList=ddYltpjieguoService.findBiaojuelist(ppxiangmuId,mmYltpXiangmu.getXiangmuleixing(),ppuserId);

             if(mmList!=null){
                for (int i = 0; i < mmList.size(); i++){
                    Hcjieguo mmYltpJieguo=new Hcjieguo();
                    String mmdetailId=mmList.get(i).get("id").toString();
                    String mmpinzhong=mmList.get(i).get("zongxuhao").toString();
                    String mmpinpai=mmList.get(i).get("pinpai").toString();
                    if(hcjieguoService.checkexistBydetailanduserId(mmdetailId,ppuserId)!=null){
                        String mmId=hcjieguoService.checkexistBydetailanduserId(mmdetailId,ppuserId).getId();
                        mmYltpJieguo.setId(mmId);
                        mmYltpJieguo.setResult(ppresult);
                        hcjieguoService.modify(mmYltpJieguo);
                    }else if (mmList.get(i).get("isvote").toString().equals("1")){
                        mmYltpJieguo.setId(UUID.randomUUID().toString());
                        mmYltpJieguo.setDetailid(mmdetailId);
                        mmYltpJieguo.setUserid(ppuserId);
                        mmYltpJieguo.setPinzhong(Integer.valueOf(mmpinzhong));
                        mmYltpJieguo.setPinpai(mmpinpai);
                        mmYltpJieguo.setXiangmuid(ppxiangmuId);
                        mmYltpJieguo.setResult(ppresult);
                        mmYltpJieguo.setCreatetime(new Date());
                        hcjieguoService.add(mmYltpJieguo);
                    }
                }
            }else{
                return JsonResult.getErrorResult("表决全部错误");
            }
            return JsonResult.getSuccessResult("表决全部成功");
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/toupiao_all:error",e);
            return JsonResult.getErrorResult("jieguo/toupiao_all:error " + e.getMessage());
        }
    }


    //打印签字表
    @RequestMapping("qianzibiao")
    public void qianzibiao(HttpServletRequest request, HttpServletResponse response,
                                @RequestParam("xiangmuid") String ppxiangmuid,
                                @RequestParam("xiangmuleixing") String ppxiangmuleixing,
                                @RequestParam("userid") String ppuserid){


        try {
           /* if(("12").equals(ppxiangmuleixing)){//设备纳入签字表
                ddService.shebeiqianzibiao(ppxiangmuid, ppuserid, request, response);
            }*/
            if(("1").equals(ppxiangmuleixing)){//引进签字表
                ddService.yinjinqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("18").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.hc1qianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("19").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.hc2qianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("20").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.hc3qianzibiao(ppxiangmuid, ppuserid, request, response);
            }
//            if(("21").equals(ppxiangmuleixing)){//引进签字表
//                ddYltpjieguoService.hc4qianzibiao(ppxiangmuid, ppuserid, request, response);
//            }
//            if(("22").equals(ppxiangmuleixing)){//引进签字表
//                ddYltpjieguoService.hc5qianzibiao(ppxiangmuid, ppuserid, request, response);
//            }
            if(("23").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.hc6qianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("24").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.Oneqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("29").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.OnePinzhongqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("25").equals(ppxiangmuleixing)||("27").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.TwoFourqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("26").equals(ppxiangmuleixing)||("28").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.ThreeFiveqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("17").equals(ppxiangmuleixing)){//引进签字表
                ddYltpjieguoService.yuxuanhuiqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
          /*  if(("2").equals(ppxiangmuleixing)){
                ddService.baofeiqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("8").equals(ppxiangmuleixing)){
                ddService.dailiangqianzibiao(ppxiangmuid, ppuserid, request, response);
            }
            if(("9").equals(ppxiangmuleixing)){
                ddService.dailiangqianzibiao(ppxiangmuid, ppuserid, request, response);
            }*/

        } catch (Exception e) {
            e.printStackTrace();
        }
        /*  List<List<String>> mmResultList = new ArrayList<List<String>>();
        String mmSheetName="";
        if(("1").equals(ppxiangmuleixing)){
           ddService.daochuqianzibiao(ppxiangmuid, ppuserid, request, response);

        }else if(("2").equals(ppxiangmuleixing)){
            mmSheetName="医疗设备报废审核表";
            mmResultList= getbaofeiqzb(ppxiangmuid,ppuserid);
        }
      else if(("3").equals(ppxiangmuleixing)){
            mmSheetName="医用耗材平台对标结果";
            mmResultList= gethaocaiduibiaoqzb(ppxiangmuid,ppuserid);
        }
        else if(("4").equals(ppxiangmuleixing)){
            mmSheetName="一对一专科耗材换标表决表";
            mmResultList= getzhuankeyinjinqzb(ppxiangmuid,ppuserid);
        }
        else if(("5").equals(ppxiangmuleixing)){
            mmSheetName="医用耗材引进申请表决表";
            mmResultList= gethaocaiyinjinqzb(ppxiangmuid,ppuserid);
        }

        try {
            //取出文档存放的根目录，并去除文件最后的斜杠
            if (userfilepath.endsWith("/")) {
                userfilepath = userfilepath.substring(0, userfilepath.length()-1);
            }

            SimpleDateFormat mmDateFormat = new SimpleDateFormat("yyyyMMdd");
            String mmSavePath = userfilepath +  "/temp/jieguo/"+mmDateFormat.format(new Date()) + "/";

            CreateXLS.createExcel(mmResultList, mmSavePath,  "qzb_"+ UUID.randomUUID().toString()+".xls",
                    mmSheetName, request, response);
            return "/ylsbtp/qianzibiao.xls";

        }
        catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return e.getMessage();
        }*/
    }

    @RequestMapping("huizongbiao")
    public void huizongbiao(HttpServletRequest request, HttpServletResponse response,
                             @RequestParam("xiangmuid") String ppxiangmuid,
                             @RequestParam("xiangmuleixing") String ppxiangmuleixing){

        try {
            List<Map<String, Object>> mmUserList=ddYltprenyuanfenpeiService.findRenyuanFenpeiByXiangmuId(ppxiangmuid);
            for(int i=0;i<mmUserList.size();i++){
                Map<String,Object> mmMap=mmUserList.get(i);
                String mmSubmit = mmMap.get("issubmit") == null ? "" : mmMap.get("issubmit").toString();
                if("0".equals(mmSubmit)){
                    error("该项目有委员没有提交结果表",response);
                    return;
                }
            }

            if(("17").equals(ppxiangmuleixing)){
                ddService.yuxuanhuihuizongbiao(ppxiangmuid, request, response);
            }
            if(("18").equals(ppxiangmuleixing)){
                ddService.hc1huizongbiao(ppxiangmuid, request, response);
            }
            if(("19").equals(ppxiangmuleixing)){
                ddService.hc2huizongbiao(ppxiangmuid, request, response);
            }
            if(("20").equals(ppxiangmuleixing)){
                ddService.hc3huizongbiao(ppxiangmuid, request, response);
            }
//            if(("21").equals(ppxiangmuleixing)){
//                ddService.hc4huizongbiao(ppxiangmuid, request, response);
//            }
//            if(("22").equals(ppxiangmuleixing)){
//                ddService.hc5huizongbiao(ppxiangmuid, request, response);
//            }
            if(("23").equals(ppxiangmuleixing)){
                ddService.hc6huizongbiao(ppxiangmuid, request, response);
            }
            if(("24").equals(ppxiangmuleixing)){
                ddService.Onehuizongbiao(ppxiangmuid, request, response);
            }
            if(("29").equals(ppxiangmuleixing)){
                ddService.OnePinzhonghuizongbiao(ppxiangmuid, request, response);
            }
            if(("25").equals(ppxiangmuleixing)||("27").equals(ppxiangmuleixing)){
                ddService.TwoFourhuizongbiao(ppxiangmuid, request, response);
            }
            if(("26").equals(ppxiangmuleixing)||("28").equals(ppxiangmuleixing)){
                ddService.ThreeFivehuizongbiao(ppxiangmuid, request, response);
            }
            if(("12").equals(ppxiangmuleixing)){ //设备汇总表
                ddService.shebeihuizongbiao(ppxiangmuid, request, response);
            }
            if(("1").equals(ppxiangmuleixing)){//引进汇总表
                ddService.yinjinhuizongbiao(ppxiangmuid, request, response);
            }
            if(("2").equals(ppxiangmuleixing)){
                ddService.baofeihuizongbiao(ppxiangmuid, request, response);
            }
            if(("8").equals(ppxiangmuleixing)){
                ddService.dailiangchuangxinhuizongbiao(ppxiangmuid, request, response);
            }
            if(("9").equals(ppxiangmuleixing)){
                ddService.dailiangchuangxinhuizongbiao(ppxiangmuid, request, response);
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
       /* List<List<String>> mmResultList = new ArrayList<List<String>>();
        if(("1").equals(ppxiangmuleixing)){
            mmResultList= getyinjinhzb(ppxiangmuid);

        }else if(("2").equals(ppxiangmuleixing)){
            mmResultList= getbaofeihzb(ppxiangmuid);
        }
        else if(("3").equals(ppxiangmuleixing)){
            mmResultList= gethaocaiduibiaohzb(ppxiangmuid);
        }
        else if(("4").equals(ppxiangmuleixing)){
            mmResultList= getzhuankeyinjinhzb(ppxiangmuid);
        }

        try {
            //取出文档存放的根目录，并去除文件最后的斜杠
            if (userfilepath.endsWith("/")) {
                userfilepath = userfilepath.substring(0, userfilepath.length()-1);
            }

            SimpleDateFormat mmDateFormat = new SimpleDateFormat("yyyyMMdd");
            String mmSavePath = userfilepath +  "/temp/jieguo/"+mmDateFormat.format(new Date()) + "/";

            CreateXLS.createExcel(mmResultList, mmSavePath,  "hzb_"+ UUID.randomUUID().toString()+".xls",
                    "hzb", request, response);
            return "/ylsbtp/huizongbiao.xls";

        }
        catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
            return e.getMessage();
        }*/
    }
    public void error(String string,HttpServletResponse mmResponse) {
        try {
            mmResponse.setCharacterEncoding("gbk");
            PrintWriter mmOut;
            mmOut = mmResponse.getWriter();
            mmOut.print("<div style='text-align:center;font-size:18px; font-weight:weight;'>"+string+"</div>");
            mmOut.flush();
            mmOut.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }


    public List<List<String>> getyinjinqzb(String ppxiangmuid,String ppuserid){
        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("科室名称");
        mmTitleList.add("设备名称");
        mmTitleList.add("预算单价");
        mmTitleList.add("数量");
        mmTitleList.add("预算金额");
        mmTitleList.add("设备类型");
        mmTitleList.add("通用名称");
        mmTitleList.add("备注");
        mmTitleList.add("表决建议");
        mmTitleList.add("表决人");
        mmResultList.add(mmTitleList);

        List<Map<String, Object>> mmList=ddYltpyinjinService.findBiaojuelist(ppxiangmuid,ppuserid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                Map<String, Object> mmMap=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmshiyongkeshi=mmMap.get("shiyongkeshi")==null ? "" :mmMap.get("shiyongkeshi").toString();
                String mmshebeimingcheng=mmMap.get("shebeimingcheng")==null ? "" :mmMap.get("shebeimingcheng").toString();
                String mmshuliang=mmMap.get("shuliang")==null ? "" :mmMap.get("shuliang").toString();
                String mmdanjia=mmMap.get("danjia")==null ? "" :mmMap.get("danjia").toString();
                String mmyusuanjine=mmMap.get("yusuanjine")==null ? "" :mmMap.get("yusuanjine").toString();
                String mmshebeileixing=mmMap.get("shebeileixing")==null ? "" :mmMap.get("shebeileixing").toString();
                String mmtongyongmingcheng=mmMap.get("tongyongmingcheng")==null ? "" :mmMap.get("tongyongmingcheng").toString();
                String mmbeizhu=mmMap.get("beizhu")==null ? "" :mmMap.get("beizhu").toString();
                String mmresult=mmMap.get("result")==null ? "" :mmMap.get("result").toString();
                String mmbiaojueren=mmMap.get("username")==null ? "" :mmMap.get("username").toString();
                String mmyijian="";
                if("1".equals(mmresult)){
                    mmyijian="通过";
                }else if("0".equals(mmresult)){
                    mmyijian="不通过";
                }else {
                    mmyijian="未表决";
                }
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmshiyongkeshi);
                mmTempList.add(mmshebeimingcheng);
                mmTempList.add(mmdanjia);
                mmTempList.add(mmshuliang);
                mmTempList.add(mmyusuanjine);
                mmTempList.add(mmshebeileixing);
                mmTempList.add(mmtongyongmingcheng);
                mmTempList.add(mmbeizhu);
                mmTempList.add(mmyijian);
                mmTempList.add(mmbiaojueren);
                mmResultList.add(mmTempList);
            }
        }
        return  mmResultList;
    }
    public List<List<String>> getbaofeiqzb(String ppxiangmuid,String ppuserid){

        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("使用科室");
        mmTitleList.add("设备名称");
        mmTitleList.add("规格型号");
        mmTitleList.add("设备价值");
        mmTitleList.add("数量");
        mmTitleList.add("生产厂商");
        mmTitleList.add("来源");
        mmTitleList.add("采购时间");
        mmTitleList.add("表决建议");
        mmTitleList.add("表决人");
        mmResultList.add(mmTitleList);

        List<Map<String, Object>> mmList=ddYltpbaofeiService.findBiaojuelist(ppxiangmuid,ppuserid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                Map<String, Object> mmMap=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmshiyongkeshi=mmMap.get("shiyongkeshi")==null ? "" :mmMap.get("shiyongkeshi").toString();
                String mmshebeimingcheng=mmMap.get("shebeimingcheng")==null ? "" :mmMap.get("shebeimingcheng").toString();
                String mmguigexinghao=mmMap.get("guigexinghao")==null ? "" :mmMap.get("guigexinghao").toString();
                String mmshebeijiazhi=mmMap.get("shebeijiazhi")==null ? "" :mmMap.get("shebeijiazhi").toString();
                String mmshuliang=mmMap.get("shuliang")==null ? "" :mmMap.get("shuliang").toString();
                String mmshengchanchangshang=mmMap.get("shengchanchangshang")==null ? "" :mmMap.get("shengchanchangshang").toString();
                String mmlaiyuan=mmMap.get("laiyuan")==null ? "" :mmMap.get("laiyuan").toString();
                String mmcaigoushijian=mmMap.get("caigoushijian")==null ? "" :mmMap.get("caigoushijian").toString();
                String mmresult=mmMap.get("result")==null ? "" :mmMap.get("result").toString();
                String mmbiaojueren=mmMap.get("username")==null ? "" :mmMap.get("username").toString();
                String mmyijian="";
                if("1".equals(mmresult)){
                    mmyijian="通过";
                }else if("0".equals(mmresult)){
                    mmyijian="不通过";
                }else {
                    mmyijian="未表决";
                }
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmshiyongkeshi);
                mmTempList.add(mmshebeimingcheng);
                mmTempList.add(mmguigexinghao);
                mmTempList.add(mmshebeijiazhi);
                mmTempList.add(mmshuliang);
                mmTempList.add(mmshengchanchangshang);
                mmTempList.add(mmlaiyuan);
                mmTempList.add(mmcaigoushijian);
                mmTempList.add(mmyijian);
                mmTempList.add(mmbiaojueren);
                mmResultList.add(mmTempList);
            }
        }

        return  mmResultList;
    }
    public List<List<String>> gethaocaiduibiaoqzb(String ppxiangmuid,String ppuserid){

        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("注册证名称");
        mmTitleList.add("注册证规格");
        mmTitleList.add("注册证号");
        mmTitleList.add("生产厂家");
        mmTitleList.add("计价单位");
        mmTitleList.add("采购价（元）");
        mmTitleList.add("使用科室");
        mmTitleList.add("平台编码");
        mmTitleList.add("表决建议");
        mmTitleList.add("表决人");
        mmResultList.add(mmTitleList);

        List<Map<String, Object>> mmList=ddYltphaocaiduibiaoService.findBiaojuelist(ppxiangmuid,ppuserid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                Map<String, Object> mmMap=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmMingcheng=mmMap.get("mingcheng")==null ? "" :mmMap.get("mingcheng").toString();
                String mmGuige=mmMap.get("guige")==null ? "" :mmMap.get("guige").toString();
                String mmZhucezhengmingcheng=mmMap.get("zhucezhengmingcheng")==null ? "" :mmMap.get("zhucezhengmingcheng").toString();
                String mmZhucezhengguige=mmMap.get("zhucezhengguige")==null ? "" :mmMap.get("zhucezhengguige").toString();
                String mmZhucezhenghao=mmMap.get("zhucezhenghao")==null ? "" :mmMap.get("zhucezhenghao").toString();
                String mmShengchanchangjia=mmMap.get("shengchanchangjia")==null ? "" :mmMap.get("shengchanchangjia").toString();
                String mmJijiadanwei=mmMap.get("jijiadanwei")==null ? "" :mmMap.get("jijiadanwei").toString();
                String mmCaigoujia=mmMap.get("caigoujia")==null ? "" :mmMap.get("caigoujia").toString();
                String mmShiyongkeshi=mmMap.get("shiyongkeshi")==null ? "" :mmMap.get("shiyongkeshi").toString();
                String mmPingtaibianma=mmMap.get("pingtaibianma")==null ? "" :mmMap.get("pingtaibianma").toString();
                String mmresult=mmMap.get("result")==null ? "" :mmMap.get("result").toString();
                String mmbiaojueren=mmMap.get("username")==null ? "" :mmMap.get("username").toString();
                String mmyijian="";
                if("1".equals(mmresult)){
                    mmyijian="通过";
                }else if("0".equals(mmresult)){
                    mmyijian="不通过";
                }else {
                    mmyijian="未表决";
                }
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmMingcheng);
                mmTempList.add(mmGuige);
                mmTempList.add(mmZhucezhengmingcheng);
                mmTempList.add(mmZhucezhengguige);
                mmTempList.add(mmZhucezhenghao);
                mmTempList.add(mmShengchanchangjia);
                mmTempList.add(mmJijiadanwei);
                mmTempList.add(mmCaigoujia);
                mmTempList.add(mmShiyongkeshi);
                mmTempList.add(mmPingtaibianma);
                mmTempList.add(mmyijian);
                mmTempList.add(mmbiaojueren);
                mmResultList.add(mmTempList);
            }
        }

        return  mmResultList;
    }
    public List<List<String>> getzhuankeyinjinqzb(String ppxiangmuid,String ppuserid){

        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("需求科室");
        mmTitleList.add("耗材编号");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("生产厂家");
        mmTitleList.add("单价");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("生产厂家");
        mmTitleList.add("单价");
        mmTitleList.add("中标信息（中标编码）");
        mmTitleList.add("表决建议");
        mmTitleList.add("表决人");
        mmResultList.add(mmTitleList);

        List<Map<String, Object>> mmList=ddYltpzhuankeyinjinService.findBiaojuelist(ppxiangmuid,ppuserid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                Map<String, Object> mmMap=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmXuqiukeshi=mmMap.get("xuqiukeshi")==null ? "" :mmMap.get("xuqiukeshi").toString();
                String mmHaocaibianhao=mmMap.get("haocaibianhao")==null ? "" :mmMap.get("haocaibianhao").toString();
                String mmXianyong_mingcheng=mmMap.get("xianyong_mingcheng")==null ? "" :mmMap.get("xianyong_mingcheng").toString();
                String mmXianyong_guige=mmMap.get("xianyong_guige")==null ? "" :mmMap.get("xianyong_guige").toString();
                String mmXianyong_shengchanchangjia=mmMap.get("xianyong_shengchanchangjia")==null ? "" :mmMap.get("xianyong_shengchanchangjia").toString();
                String mmXianyong_danjia=mmMap.get("xianyong_danjia")==null ? "" :mmMap.get("xianyong_danjia").toString();
                String mmNigeng_mingcheng=mmMap.get("nigeng_mingcheng")==null ? "" :mmMap.get("nigeng_mingcheng").toString();
                String mmNigeng_guige=mmMap.get("nigeng_guige")==null ? "" :mmMap.get("nigeng_guige").toString();
                String mmNigeng_shengchanchangjia=mmMap.get("nigeng_shengchanchangjia")==null ? "" :mmMap.get("nigeng_shengchanchangjia").toString();
                String mmNigeng_danjia=mmMap.get("nigeng_danjia")==null ? "" :mmMap.get("nigeng_danjia").toString();
                String mmZhongbiaoxinxi=mmMap.get("zhongbiaoxinxi")==null ? "" :mmMap.get("zhongbiaoxinxi").toString();
                String mmresult=mmMap.get("result")==null ? "" :mmMap.get("result").toString();
                String mmbiaojueren=mmMap.get("username")==null ? "" :mmMap.get("username").toString();
                String mmyijian="";
                if("1".equals(mmresult)){
                    mmyijian="通过";
                }else if("0".equals(mmresult)){
                    mmyijian="不通过";
                }else {
                    mmyijian="未表决";
                }
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmXuqiukeshi);
                mmTempList.add(mmHaocaibianhao);
                mmTempList.add(mmXianyong_mingcheng);
                mmTempList.add(mmXianyong_guige);
                mmTempList.add(mmXianyong_shengchanchangjia);
                mmTempList.add(mmXianyong_danjia);
                mmTempList.add(mmNigeng_mingcheng);
                mmTempList.add(mmNigeng_guige);
                mmTempList.add(mmNigeng_shengchanchangjia);
                mmTempList.add(mmNigeng_danjia);
                mmTempList.add(mmZhongbiaoxinxi);
                mmTempList.add(mmyijian);
                mmTempList.add(mmbiaojueren);
                mmResultList.add(mmTempList);
            }
        }

        return  mmResultList;
    }
    public List<List<String>> gethaocaiyinjinqzb(String ppxiangmuid,String ppuserid){

        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("品种");
        mmTitleList.add("品牌");
        mmTitleList.add("型号拆分");
        mmTitleList.add("平台编码");
        mmTitleList.add("注册证名称");
        mmTitleList.add("规格");
        mmTitleList.add("型号");
        mmTitleList.add("注册证号");
        mmTitleList.add("生产商");
        mmTitleList.add("计价单位");
        mmTitleList.add("平台情况（江苏省/南京市/申请备案）");
        mmTitleList.add("平台单价（元）");
        mmTitleList.add("南京市医保码（CLXXXXXXXX)");
        mmTitleList.add("简要功能用途（20字左右）");
        mmTitleList.add("表决建议");
        mmTitleList.add("表决人");
        mmResultList.add(mmTitleList);

        List<Map<String, Object>> mmList=ddHaocaiyinjinService.findBiaojuelist(ppxiangmuid,ppuserid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                Map<String, Object> mmMap=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmPinzhong=mmMap.get("pinzhong")==null ? "" :mmMap.get("pinzhong").toString();
                String mmpinpai=mmMap.get("pinpai")==null ? "" :mmMap.get("pinpai").toString();
                String mmxinghaochaifen=mmMap.get("xinghaochaifen")==null ? "" :mmMap.get("xinghaochaifen").toString();
                String mmpingtaibianma=mmMap.get("pingtaibianma")==null ? "" :mmMap.get("pingtaibianma").toString();
                String mmzhucezhengmingcheng=mmMap.get("zhucezhengmingcheng")==null ? "" :mmMap.get("zhucezhengmingcheng").toString();
                String mmguige=mmMap.get("guige")==null ? "" :mmMap.get("guige").toString();
                String mmxinghao=mmMap.get("xinghao")==null ? "" :mmMap.get("xinghao").toString();
                String mmzhucezhenghao=mmMap.get("zhucezhenghao")==null ? "" :mmMap.get("zhucezhenghao").toString();
                String mmshengchanshang=mmMap.get("shengchanshang")==null ? "" :mmMap.get("shengchanshang").toString();
                String mmjijiadanwei=mmMap.get("jijiadanwei")==null ? "" :mmMap.get("jijiadanwei").toString();
                String mmpingtaiqingkuang=mmMap.get("pingtaiqingkuang")==null ? "" :mmMap.get("pingtaiqingkuang").toString();
                String mmpingtaidanjia=mmMap.get("pingtaidanjia")==null ? "" :mmMap.get("pingtaidanjia").toString();
                String mmnanjingshiyibaoma=mmMap.get("nanjingshiyibaoma")==null ? "" :mmMap.get("nanjingshiyibaoma").toString();
                String mmgongnengyongtu=mmMap.get("gongnengyongtu")==null ? "" :mmMap.get("gongnengyongtu").toString();
                String mmresult=mmMap.get("result")==null ? "" :mmMap.get("result").toString();
                String mmbiaojueren=mmMap.get("username")==null ? "" :mmMap.get("username").toString();
                String mmyijian="";
                if("1".equals(mmresult)){
                    mmyijian="通过";
                }else if("0".equals(mmresult)){
                    mmyijian="不通过";
                }else {
                    mmyijian="未表决";
                }
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmPinzhong);
                mmTempList.add(mmpinpai);
                mmTempList.add(mmxinghaochaifen);
                mmTempList.add(mmpingtaibianma);
                mmTempList.add(mmzhucezhengmingcheng);
                mmTempList.add(mmguige);
                mmTempList.add(mmxinghao);
                mmTempList.add(mmzhucezhenghao);
                mmTempList.add(mmshengchanshang);
                mmTempList.add(mmjijiadanwei);
                mmTempList.add(mmpingtaiqingkuang);
                mmTempList.add(mmpingtaidanjia);
                mmTempList.add(mmnanjingshiyibaoma);
                mmTempList.add(mmgongnengyongtu);
                mmTempList.add(mmyijian);
                mmTempList.add(mmbiaojueren);
                mmResultList.add(mmTempList);
            }
        }

        return  mmResultList;
    }

    public List<List<String>> getyinjinhzb(String ppxiangmuid){
        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("科室名称");
        mmTitleList.add("设备名称");
        mmTitleList.add("预算单价");
        mmTitleList.add("数量");
        mmTitleList.add("预算金额");
        mmTitleList.add("设备类型");
        mmTitleList.add("通用名称");
        mmTitleList.add("备注");
        mmTitleList.add("表决结果");
        mmTitleList.add("是否通过");
        mmResultList.add(mmTitleList);

        YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuid);
        int mmtongguopiaoshu=mmYltpXiangmu.getTongguoshu();

        List<YltpYinjin> mmList=ddYltpyinjinService.findyinjinlist(ppxiangmuid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                YltpYinjin mmYltpYinjin=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmshiyongkeshi=mmYltpYinjin.getShiyongkeshi()==null ? "" :mmYltpYinjin.getShiyongkeshi();
                String mmshebeimingcheng=mmYltpYinjin.getShebeimingcheng()==null ? "" :mmYltpYinjin.getShebeimingcheng();
                String mmshuliang=mmYltpYinjin.getShuliang()==null ? "" :mmYltpYinjin.getShuliang();
                String mmdanjia=mmYltpYinjin.getDanjia()==null ? "" :mmYltpYinjin.getDanjia();
                String mmyusuanjine=mmYltpYinjin.getYusuanjine()==null ? "" :mmYltpYinjin.getYusuanjine();
                String mmshebeileixing=mmYltpYinjin.getShebeimingcheng()==null ? "" :mmYltpYinjin.getShebeimingcheng();
                String mmtongyongmingcheng=mmYltpYinjin.getTongyongmingcheng()==null ?"":mmYltpYinjin.getTongyongmingcheng();
                String mmbeizhu=mmYltpYinjin.getBeizhu()==null ?"":mmYltpYinjin.getBeizhu();
                String mmdetailId=mmYltpYinjin.getId()==null ? "" :mmYltpYinjin.getId();
                int mmtongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"1");
                int mmbutongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"0");
                String mmresult="同意："+mmtongguoshu+"，不同意："+mmbutongguoshu;
                String mmshifoutongguo=mmtongguoshu>=mmtongguopiaoshu?"是":"否";
                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmshiyongkeshi);
                mmTempList.add(mmshebeimingcheng);
                mmTempList.add(mmdanjia);
                mmTempList.add(mmshuliang);
                mmTempList.add(mmyusuanjine);
                mmTempList.add(mmshebeileixing);
                mmTempList.add(mmtongyongmingcheng);
                mmTempList.add(mmbeizhu);
                mmTempList.add(mmresult);
                mmTempList.add(mmshifoutongguo);
                mmResultList.add(mmTempList);
            }
        }

        return  mmResultList;
    }
    public List<List<String>> getbaofeihzb(String ppxiangmuid){
        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("使用科室");
        mmTitleList.add("设备名称");
        mmTitleList.add("规格型号");
        mmTitleList.add("设备价值");
        mmTitleList.add("数量");
        mmTitleList.add("生产厂商");
        mmTitleList.add("来源");
        mmTitleList.add("采购时间");
        mmTitleList.add("表决结果");
        mmTitleList.add("是否通过");
        mmResultList.add(mmTitleList);

        YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuid);
        int mmtongguopiaoshu=mmYltpXiangmu.getTongguoshu();

        List<YltpBaofei> mmList=ddYltpbaofeiService.findBaofeilist(ppxiangmuid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                YltpBaofei mmYltpBaofei=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmshiyongkeshi=mmYltpBaofei.getShiyongkeshi()==null ? "" :mmYltpBaofei.getShiyongkeshi();
                String mmshebeimingcheng=mmYltpBaofei.getShengchanchangshang()==null ? "" :mmYltpBaofei.getShengchanchangshang();
                String mmguigexinghao=mmYltpBaofei.getGuigexinghao()==null ? "" :mmYltpBaofei.getGuigexinghao();
                String mmshebeijiazhi=mmYltpBaofei.getShebeijiazhi()==null ? "" :mmYltpBaofei.getShebeijiazhi();
                String mmshuliang=mmYltpBaofei.getShuliang()==null ? "" :mmYltpBaofei.getShuliang();
                String mmshengchanchangshang=mmYltpBaofei.getShengchanchangshang()==null ? "" :mmYltpBaofei.getShengchanchangshang();
                String mmlaiyuan=mmYltpBaofei.getLaiyuan()==null ? "" :mmYltpBaofei.getLaiyuan();
                String mmcaigoushijian=mmYltpBaofei.getCaigoushijian()==null ? "" :mmYltpBaofei.getCaigoushijian();
                String mmdetailId=mmYltpBaofei.getId()==null ? "" :mmYltpBaofei.getId();
                int mmtongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"1");
                int mmbutongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"0");
                String mmresult="同意："+mmtongguoshu+"，不同意："+mmbutongguoshu;
                String mmshifoutongguo=mmtongguoshu>=mmtongguopiaoshu?"是":"否";

                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmshiyongkeshi);
                mmTempList.add(mmshebeimingcheng);
                mmTempList.add(mmguigexinghao);
                mmTempList.add(mmshebeijiazhi);
                mmTempList.add(mmshuliang);
                mmTempList.add(mmshengchanchangshang);
                mmTempList.add(mmlaiyuan);
                mmTempList.add(mmcaigoushijian);
                mmTempList.add(mmresult);
                mmTempList.add(mmshifoutongguo);
                mmResultList.add(mmTempList);

            }
        }
        return mmResultList;
    }
    public List<List<String>> gethaocaiduibiaohzb(String ppxiangmuid){
        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("注册证名称");
        mmTitleList.add("注册证规格");
        mmTitleList.add("注册证号");
        mmTitleList.add("生产厂家");
        mmTitleList.add("计价单位");
        mmTitleList.add("采购价（元）");
        mmTitleList.add("使用科室");
        mmTitleList.add("平台编码");
        mmTitleList.add("表决结果");
        mmTitleList.add("是否通过");
        mmResultList.add(mmTitleList);

        YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuid);
        int mmtongguopiaoshu=mmYltpXiangmu.getTongguoshu();
        List<YltpHaocaiduibiao> mmList=ddYltphaocaiduibiaoService.findHaocaiduibiaolist(ppxiangmuid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                YltpHaocaiduibiao mmYltpHaocaiduibiao=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmMingcheng=mmYltpHaocaiduibiao.getMingcheng()==null ? "" :mmYltpHaocaiduibiao.getMingcheng().toString();
                String mmGuige=mmYltpHaocaiduibiao.getGuige()==null ? "" :mmYltpHaocaiduibiao.getGuige().toString();
                String mmZhucezhengmingcheng=mmYltpHaocaiduibiao.getZhucezhengmingcheng()==null ? "" :mmYltpHaocaiduibiao.getZhucezhengmingcheng().toString();
                String mmZhucezhengguige=mmYltpHaocaiduibiao.getZhucezhengguige()==null ? "" :mmYltpHaocaiduibiao.getZhucezhengguige().toString();
                String mmZhucezhenghao=mmYltpHaocaiduibiao.getZhucezhenghao()==null ? "" :mmYltpHaocaiduibiao.getZhucezhenghao().toString();
                String mmShengchanchangjia=mmYltpHaocaiduibiao.getShengchanchangjia()==null ? "" :mmYltpHaocaiduibiao.getShengchanchangjia().toString();
                String mmJijiadanwei=mmYltpHaocaiduibiao.getJijiadanwei()==null ? "" :mmYltpHaocaiduibiao.getJijiadanwei().toString();
                String mmCaigoujia=mmYltpHaocaiduibiao.getCaigoujia()==null ? "" :mmYltpHaocaiduibiao.getCaigoujia().toString();
                String mmShiyongkeshi=mmYltpHaocaiduibiao.getShiyongkeshi()==null ? "" :mmYltpHaocaiduibiao.getShiyongkeshi().toString();
                String mmPingtaibianma=mmYltpHaocaiduibiao.getPingtaibianma()==null ? "" :mmYltpHaocaiduibiao.getPingtaibianma().toString();

                String mmdetailId=mmYltpHaocaiduibiao.getId()==null ? "" :mmYltpHaocaiduibiao.getId();
                int mmtongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"1");
                int mmbutongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"0");
                String mmresult="同意："+mmtongguoshu+"，不同意："+mmbutongguoshu;
                String mmshifoutongguo=mmtongguoshu>=mmtongguopiaoshu?"是":"否";

                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmMingcheng);
                mmTempList.add(mmGuige);
                mmTempList.add(mmZhucezhengmingcheng);
                mmTempList.add(mmZhucezhengguige);
                mmTempList.add(mmZhucezhenghao);
                mmTempList.add(mmShengchanchangjia);
                mmTempList.add(mmJijiadanwei);
                mmTempList.add(mmCaigoujia);
                mmTempList.add(mmShiyongkeshi);
                mmTempList.add(mmPingtaibianma);
                mmTempList.add(mmresult);
                mmTempList.add(mmshifoutongguo);
                mmResultList.add(mmTempList);

            }
        }
        return mmResultList;
    }
    public List<List<String>> getzhuankeyinjinhzb(String ppxiangmuid){
        List<List<String>> mmResultList = new ArrayList<List<String>>();
        List<String> mmTitleList = new ArrayList<String>();
        mmTitleList.add("序号");
        mmTitleList.add("需求科室");
        mmTitleList.add("耗材编号");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("生产厂家");
        mmTitleList.add("单价");
        mmTitleList.add("名称");
        mmTitleList.add("规格");
        mmTitleList.add("生产厂家");
        mmTitleList.add("单价");
        mmTitleList.add("中标信息（中标编码）");
        mmTitleList.add("表决结果");
        mmTitleList.add("是否通过");
        mmResultList.add(mmTitleList);

        YltpXiangmu mmYltpXiangmu=ddYltpXiangmuService.findOne(ppxiangmuid);
        int mmtongguopiaoshu=mmYltpXiangmu.getTongguoshu();
        List<YltpZhuankeyinjin> mmList=ddYltpzhuankeyinjinService.findZhuankeyinjinlist(ppxiangmuid);
        int mmsize = mmList.size();
        if(mmsize > 0) {
            for (int i = 0; i < mmsize; i++) {
                YltpZhuankeyinjin mmYltpZhuankeyinjin=mmList.get(i);
                String mmXuhao = String.valueOf(i + 1);
                String mmXuqiukeshi=mmYltpZhuankeyinjin.getXuqiukeshi()==null ? "" :mmYltpZhuankeyinjin.getXuqiukeshi().toString();
                String mmHaocaibianhao=mmYltpZhuankeyinjin.getHaocaibianhao()==null ? "" :mmYltpZhuankeyinjin.getHaocaibianhao().toString();
                String mmXianyong_mingcheng=mmYltpZhuankeyinjin.getXianyongMingcheng()==null ? "" :mmYltpZhuankeyinjin.getXianyongMingcheng().toString();
                String mmXianyong_guige=mmYltpZhuankeyinjin.getXianyongGuige()==null ? "" :mmYltpZhuankeyinjin.getXianyongGuige().toString();
                String mmXianyong_shengchanchangjia=mmYltpZhuankeyinjin.getXianyongDanjia()==null ? "" :mmYltpZhuankeyinjin.getXianyongDanjia().toString();
                String mmXianyong_danjia=mmYltpZhuankeyinjin.getNigengDanjia()==null ? "" :mmYltpZhuankeyinjin.getNigengDanjia().toString();
                String mmNigeng_mingcheng=mmYltpZhuankeyinjin.getNigengMingcheng()==null ? "" :mmYltpZhuankeyinjin.getNigengMingcheng().toString();
                String mmNigeng_guige=mmYltpZhuankeyinjin.getNigengGuige()==null ? "" :mmYltpZhuankeyinjin.getNigengGuige().toString();
                String mmNigeng_shengchanchangjia=mmYltpZhuankeyinjin.getNigengShengchanchangjia()==null ? "" :mmYltpZhuankeyinjin.getNigengShengchanchangjia().toString();
                String mmNigeng_danjia=mmYltpZhuankeyinjin.getNigengDanjia()==null ? "" :mmYltpZhuankeyinjin.getNigengDanjia().toString();
                String mmZhongbiaoxinxi=mmYltpZhuankeyinjin.getZhongbiaoxinxi()==null ? "" :mmYltpZhuankeyinjin.getZhongbiaoxinxi().toString();
                String mmdetailId=mmYltpZhuankeyinjin.getId()==null ? "" :mmYltpZhuankeyinjin.getId();
                int mmtongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"1");
                int mmbutongguoshu=ddYltpjieguoService.getCountBydetailIdandResult(mmdetailId,"0");
                String mmresult="同意："+mmtongguoshu+"，不同意："+mmbutongguoshu;
                String mmshifoutongguo=mmtongguoshu>=mmtongguopiaoshu?"是":"否";

                List<String> mmTempList = new ArrayList<String>();
                mmTempList.add(mmXuhao);
                mmTempList.add(mmXuqiukeshi);
                mmTempList.add(mmHaocaibianhao);
                mmTempList.add(mmXianyong_mingcheng);
                mmTempList.add(mmXianyong_guige);
                mmTempList.add(mmXianyong_shengchanchangjia);
                mmTempList.add(mmXianyong_danjia);
                mmTempList.add(mmNigeng_mingcheng);
                mmTempList.add(mmNigeng_guige);
                mmTempList.add(mmNigeng_shengchanchangjia);
                mmTempList.add(mmNigeng_danjia);
                mmTempList.add(mmZhongbiaoxinxi);
                mmTempList.add(mmresult);
                mmTempList.add(mmshifoutongguo);
                mmResultList.add(mmTempList);

            }
        }
        return mmResultList;
    }

    @RequestMapping("findBiaojuelist")
    public JsonResult<?> findBiaojuelist(@RequestParam("xiangmuid") String ppxiangmuid,
                                         @RequestParam("xiangmuleixing") String ppxiangmuleixing,
                                         @RequestParam("userid") String ppuserid){
        try {


            List<Map<String, Object>> pinguilist=ddYltpjieguoService.findBiaojuelist(ppxiangmuid,ppxiangmuleixing,ppuserid);
            String str = "";
            switch (ppxiangmuleixing){
                case "19":str=new String("zongxuhao");break;
                case "20":str=new String("zongxuhao");break;
                case "21":str=new String("zongxuhao");break;
                case "22":str=new String("zongxuhao");break;
                case "23":str=new String("xuhao");break;
                case "18":str=new String("xuhao");break;
            }
            String finalStr = str;
            List<Map<String, Object>> mmpinpailist=pinguilist.stream()
                    .filter(distinctByKey(o -> o.get(finalStr)))
                    .collect(Collectors.toList());
            List<Map<String, Object>> newPinpailist = new ArrayList<>(mmpinpailist.size());
            for (int i = 0; i < mmpinpailist.size(); i++) {
                String mmzongxuhao = mmpinpailist.get(i).get(finalStr).toString();
                List<Map<String, Object>> mmpinguilist = pinguilist.stream()
                        .filter(x -> x.get(finalStr).toString().equals(mmzongxuhao))
                        .collect(Collectors.toList());
                Map<String, Object> newItem = new HashMap<>(mmpinpailist.get(i));
                newItem.put("pinguilist", mmpinguilist);
                newItem.put("pinpaihebinghang", mmpinguilist.size());
                newPinpailist.add(newItem);
            }

            Map<String, Object> mmReturnMap = new HashMap<>();
            mmReturnMap.put("Biaojuelist", newPinpailist);
            mmReturnMap.put("Resultlist", pinguilist);
            return JsonResult.getSuccessResult(mmReturnMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/findBiaojuelist:error",e);
            return JsonResult.getErrorResult("jieguo/findBiaojuelist:error " + e.getMessage());
        }
    }
    @RequestMapping("findlist")
    public JsonResult<?> findlist(@RequestParam("xiangmuid") String ppxiangmuid,
                                         @RequestParam("xiangmuleixing") String ppxiangmuleixing){
        try {


            List<Map<String, Object>> pinguilist=ddYltpjieguoService.findlist(ppxiangmuid,Tablename.getTablename(ppxiangmuleixing));
            String str = "";
            switch (ppxiangmuleixing){
                case "19":str=new String("zongxuhao");break;
                case "20":str=new String("zongxuhao");break;
                case "21":str=new String("zongxuhao");break;
                case "22":str=new String("zongxuhao");break;
                case "18":str=new String("xuhao");break;
            }
            String finalStr = str;
            List<Map<String, Object>> mmpinpailist=pinguilist.stream()
                    .filter(distinctByKey(o -> o.get(finalStr)))
                    .collect(Collectors.toList());
            List<Map<String, Object>> newPinpailist = new ArrayList<>(mmpinpailist.size());
            for (int i = 0; i < mmpinpailist.size(); i++) {
                String mmzongxuhao = mmpinpailist.get(i).get(finalStr).toString();
                List<Map<String, Object>> mmpinguilist = pinguilist.stream()
                        .filter(x -> x.get(finalStr).toString().equals(mmzongxuhao))
                        .collect(Collectors.toList());
                Map<String, Object> newItem = new HashMap<>(mmpinpailist.get(i));
                newItem.put("pinguilist", mmpinguilist);
                newItem.put("pinpaihebinghang", mmpinguilist.size());
                newPinpailist.add(newItem);
            }

            Map<String, Object> mmReturnMap = new HashMap<>();
            mmReturnMap.put("Biaojuelist", newPinpailist);
            mmReturnMap.put("Resultlist", pinguilist);
            return JsonResult.getSuccessResult(mmReturnMap);
        }catch (Exception e) {
            e.printStackTrace();
            log.error("jieguo/findBiaojuelist:error",e);
            return JsonResult.getErrorResult("jieguo/findBiaojuelist:error " + e.getMessage());
        }
    }
    public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
        Map<Object, Boolean> seen = new ConcurrentHashMap<>();
        return object -> seen.putIfAbsent(keyExtractor.apply(object), Boolean.TRUE) == null;
    }

}
